<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$basic=$this->plugin_setting('basic');
$return['hdps']=$basic['hdps'];
if($_RQ['op']=='main'){

	set_html('title','患者列表');
	exi($return);
}
if($_RQ['op']=='getlist'){
  
	$params=array('workerid'=>$this->worker_id,'uniacid'=>$_SESSION['uniacid']);
	
	//排序门店
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'fields'=>$fields,
		'orderby'=>$orderby,
	);

	$list=pdo_getslice('jy_yiliao_worker_user',$params,array($pindex,$psize),$total,$fields,'','id desc');
	
	$sum=0;
	if($list){
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$user=pdo_get('jy_yiliao_user',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
			$item['bodytitle']=$user['name'];
			$item['bodyphone']=$user['mobile'];
			$item['birth']=json_decode($user['birth'],true);
			$item['year']=$item['birth']['year'];
			if($item['bodyid']>0){
				$body=pdo_get('jy_yiliao_body',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['bodyid']),array('name','sex','agetime'));
				$item['jrname']=$body['name'];
				$item['sex']=$body['sex'];
				$item['year']=date('Y',$body['agetime']);
			}
			$item['bodysex']=$item['sex']==0?'女':'男';
			$item['bodyage']=$item['year']>0?date('Y')-$item['year']:'无';
			$item['from_type']=$this->from_type[$user['from_type']];
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		}
	}

	$return['list']=$list;
	$return['sum']=$sum;
	set_html('title','患者列表');
	exi($return);
}